package com.sgb.kjwl.view.ui.adapter.self.publish;


import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.databinding.library.baseAdapters.BR;

import com.sgb.kjwl.R;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class ConcreteSelectAdapter extends BaseRecycleAdapter<String> {

    private TextView mTvName;
    private TextView mDeleteTv;
    private Idelete idelete;

    public ConcreteSelectAdapter(Context context, List<String> datas) {
        super(context, R.layout.item_concrete_select, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final String entity) {
        holder.setBinding(BR.viewModel, entity);
        mTvName = holder.getItem().findViewById(R.id.tv_name);
        mDeleteTv = holder.getItem().findViewById(R.id.delete_tv);
        mTvName.setText(entity);
        if (holder.getAdapterPosition() == 0 || holder.getAdapterPosition() == 1) {
            mDeleteTv.setVisibility(View.GONE);
        }
        mDeleteTv.setOnClickListener(view ->
                idelete.onDelete(holder.getAdapterPosition()));
    }

    public interface Idelete {
        void onDelete(int position);
    }

    public void Idelete(Idelete idelete) {
        this.idelete = idelete;
    }

}
